package com.liang.spring.test.controller;
import java.io.PrintWriter;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.liang.spring.test.dao.ParamInfoMapper;
import com.liang.spring.test.controller.entity.ParamInfoExample;
import com.liang.spring.test.controller.entity.ParamInfo;

/**
 * 设置特殊参数
 * @author think
 *
 */
@Controller
@RequestMapping(value = "/paramininfo")
public class paramController {

	@Autowired
	private ParamInfoMapper paraminfomapper;

	@RequestMapping(value = "/sel")
	public String sel(Model model){
		try {		
			ParamInfoExample paraminfo = new ParamInfoExample();
			List<ParamInfo> paramList = paraminfomapper.selectByExample(paraminfo);
			model.addAttribute("paramList", paramList);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			
		}
		return "/tsParam";
	}
	
	@RequestMapping(value = "/update")
	public String update(ParamInfo paramInfo, PrintWriter printWriter){
		try {		
			ParamInfoExample paraminfo = new ParamInfoExample();
			paramInfo.setFid(1);
			paraminfomapper.updateByExample(paramInfo, paraminfo);
			String jsonString = JSON.toJSONString("成功", SerializerFeature.PrettyFormat);  
	        printWriter.write(jsonString);  
	        printWriter.flush();  
	        printWriter.close();  
		} catch (Exception e) {
			String jsonString = JSON.toJSONString("失败", SerializerFeature.PrettyFormat);  
	        printWriter.write(jsonString);  
	        printWriter.flush();  
	        printWriter.close();  
		} finally {
			
		}
		return "/tsParam";
	}	
}
